package com.base.cn.platform.os.common.mybatis.sharding;

import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 删除Sql
 *
 * @author s.li
 * @create 2019-05-23 11:39
 */
public class DeleteSql {

    public static void delete(MySqlDeleteStatement deleteStatement, List<SQLExprTableSource> tableNameList, Set<String> columnSet, Map<String,Object> shardingValues){
        SQLTableSource sqlTableSource = deleteStatement.getTableSource();
        if(tableNameList !=null){
            tableNameList.add((SQLExprTableSource)sqlTableSource);
        }
        SQLExpr sqlExpr = deleteStatement.getWhere();
        if(sqlExpr !=null){
            WhereSql.whereHandle(sqlExpr,tableNameList,columnSet,shardingValues);
        }
    }
}
